#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


int main()
{
//    printf("%d\n",BUFSIZ);
    FILE * read_fp;
    char buffer[BUFSIZ +1];
    int chars_read;
    memset(buffer,'\0',sizeof(buffer));
//    read_fp = popen("uname -a","r");
    read_fp = popen("wc","w");
    if (read_fp != NULL){
/*        chars_read = fread(buffer,sizeof(char),BUFSIZ,read_fp);//从指定的文件指针流read_fp中读取BUFSIZ个数据项到buffer中，一个数据项的大小为sizeof(char);
        
        if (chars_read > 0){
            printf("Output was :-\n%s\n",buffer);
  */    
            fgets(buffer,BUFSIZ,stdin);
            printf("%s\n",buffer);
            fwrite(buffer,sizeof(char),strlen(buffer)/sizeof(char)-1,read_fp);
            
    }
            
        pclose(read_fp);
        exit(EXIT_SUCCESS);

    
    exit(EXIT_FAILURE);

}
